home *** CD-ROM | disk | FTP | other *** search
/ QuickTime for the Web (2nd Edition) / QuickTime for the Web (2nd Edition).iso / pc / Demos / Mac / Matthew's Behaviors / Matthew'sMotionƒ / rollaround < prev    next >
Encoding:
INI File  |  2001-09-10  |  2.6 KB  |  79 lines

  1. [Name]
  2. RollAround - From Matthew's Motion Suite.
  3. By Matthew Peterson, matthew@pinoko.berkeley.edu
  4.  
  5. [Description]
  6. 2-19-2000
  7. Drop this on a sprite, and it will roll around the edge of the sprite track.
  8.  
  9. [Parameters]
  10.  
  11. Roll Direction ±1, MP_InitialRollDirection,1,-1,1
  12. Roll Speed 1-20, MP_RollAngleStep,5,1,20
  13.  
  14. [Frame loaded]
  15. Spritevars MP_whichcorner MP_currentcornerx MP_currentcornery MP_rolldirection
  16. //Initialize variables.
  17. MP_whichcorner = 4
  18. MP_rolldirection = $MP_InitialRollDirection
  19. //Move the sprite to the bottom of the track
  20. spriteofid($ThisSpriteID).moveby(trackwidth/2 - spriteofid($ThisSpriteID).boundsright,trackheight - spriteofid($ThisSpriteID).boundsbottom)
  21.  
  22. [Idle]
  23. Spritevars MP_whichcorner MP_currentcornerx MP_currentcornery MP_rolldirection
  24. localvars MP_tempcornerx MP_tempcornery
  25. //RollAround by Matthew Peterson
  26. //This is a very simple motion. A sprites rolls around the edge
  27. //of the movie pivoting around the corner of the sprite currently
  28. //touching the movie's border.
  29.  
  30. //First remember the location of the current pivoting corner
  31. executeevent(200081)
  32. //Place in temporary variable.
  33. MP_tempcornerx = MP_currentcornerx
  34. MP_tempcornery = MP_currentcornery
  35.  
  36. rotate($MP_RollAngleStep * MP_rolldirection)//rotate in the current direction
  37. executeevent(200081)//Get the new corner position so we know how much
  38. //to move the sprite by to get it in the correct position.
  39. moveby(MP_tempcornerx-MP_currentcornerx,MP_tempcornery-MP_currentcornery)
  40. //Check to see if we have rotated out of bounds. If so, then change
  41. //the pivot corner.
  42. if(boundsbottom > trackheight)
  43.     moveby(0,trackheight- boundsbottom)
  44.     MP_whichcorner = MP_whichcorner - MP_rolldirection
  45. elseif(boundsleft < 0)
  46.     moveby(- boundsleft,0)
  47.     MP_whichcorner = MP_whichcorner - MP_rolldirection
  48. elseif(boundstop < 0)
  49.     moveby(0,- boundstop)
  50.     MP_whichcorner = MP_whichcorner - MP_rolldirection
  51. elseif(boundsright > trackwidth)
  52.     moveby(trackwidth- boundsright,0)
  53.     MP_whichcorner = MP_whichcorner - MP_rolldirection
  54. endif
  55. //wrap around the four corners.
  56. if(MP_whichcorner = 0)
  57.     MP_whichcorner = 4
  58. elseif(MP_whichcorner = 5)
  59.     MP_whichcorner = 1
  60. endif
  61.  
  62.  
  63. [200081 MP_RollGetCorners]
  64. Spritevars MP_whichcorner MP_currentcornerx MP_currentcornery
  65. //Remember the location of the current
  66. //pivot corner.
  67. if(MP_whichcorner = 1)
  68. MP_currentcornerx = firstcornerx
  69. MP_currentcornery = firstcornery
  70. elseif(MP_whichcorner = 2)
  71. MP_currentcornerx = secondcornerx
  72. MP_currentcornery = secondcornery
  73. elseif(MP_whichcorner = 3)
  74. MP_currentcornerx = thirdcornerx
  75. MP_currentcornery = thirdcornery
  76. elseif(MP_whichcorner = 4)
  77. MP_currentcornerx = fourthcornerx
  78. MP_currentcornery = fourthcornery
  79. endif